﻿$(function() {
    // data_detail
    $("table.dataDetail > tbody > tr:nth-child(1)").addClass("dd_caption");
    $("table.dataDetail > tbody > tr > td:nth-child(1)").addClass("dd_c1");
    $("table.dataDetail > tbody > tr > td:nth-child(2)").addClass("dd_c2");
    $("table.dataDetail > tbody > tr > td[colspan=2]").removeClass("dd_c1");
    $("td.dd_c2").each(function() {
        if ($.trim($(this).text()).length == 0 ||
            $.trim($(this).text()) == "*") {
            $(this).parent("tr").hide();
        }
    });
    $("table.dataDetail tbody").each(function() {
        if ($.trim($(this).find("td.dd_c2").text()).length == 0 ||
            $.trim($(this).find("td.dd_c2").text()) == "*") {
            $(this).hide();
        }
    });

//    var url = /(\w+:\/\/[\w.]+\/\S*)/;
//    $("td.dd_c2").each(function() {
//        var text = $(this).text();
//        var result = text.match(url);
//        if (result != null) {
//            $(this).html(text.replace(url, "<a href=\"$1\" target=\"_blank\">$1</a>"));
//        }
//    });

    $(".dd_cover img").each(function() {
        var w = 210, h = 280;
        if (this.width > w) {
            this.height = this.height * w / this.width;
            this.width = w;
        }
        if (this.height > h) {
            this.width = this.width * h / this.height;
            this.height = h;
        }
    });
});